package esmp.bootstrap.bean;

import netty.task.NettyDeferredTaskManager;
import redis.task.DeferredResultTask;
import redis.task.LocalTaskExecutor;

public class LocalTaskExecutorImpl implements LocalTaskExecutor {
    private NettyDeferredTaskManager nettyTaskManager;

    public LocalTaskExecutorImpl(NettyDeferredTaskManager taskManager) {
        this.nettyTaskManager = taskManager;
    }

    @Override
    public void execute(DeferredResultTask<?> task) {
        if (task.getType().startsWith("netty.")) {
            task.setType(task.getType().substring(6));
            nettyTaskManager.execute(task);
        }
    }
}
